<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery.js"></script>
<script src="js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
  <div class="body-content">
    <form method="post"  id="form-x" class="form-x" action="/workview/superviseadd1">

		<div class="form-group">
			<div class="label">
				<label>请输入课程id：</label>
			</div>
			<div class="field">
				<input type="test" class="input w50" value="" name="course_id" id="course_id" data-validate="required:请输入课程id" />
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
				<label>课程名称：</label>
			</div>
			<div class="field">
				<input type="test" class="input w50" value="" name="course_name" id="course_name" data-validate="required:请输入课程名称" />
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
              <label>选择学院：</label>
            </div>

            <div class="field">
              <select name="college_name" id="college_name" class="input w50">
                <option selected="selected">请选择分类</option>
                 <option value="软件学院">软件学院</option>
                 <option value="人文学院">人文学院</option>
              </select>
               <span style="margin-left: 10px; color: red;">*</span>
              <div class="tips"></div>
            </div>
		</div>
		
		<div class="form-group">
		  <div class="label">
		    <label>成绩规则：</label>
		  </div>
		  <div class="field">
		    <!--<input type="test" class="input w50" value="" name="performance_rule_id" id="performance_rule_id" data-validate="required:请选择成绩规则" />-->
			  <select name="performance_rule_id" id="performance_rule_id" class="input w50">
				  <option selected="selected">请选择分类</option>
				  <option value="1">1</option>
				  <option value="2">2</option>
			  </select>
		    <span style="margin-left: 10px; color: red;">*</span>
		    <div class="tips"> </div>
		  </div>
		</div>

      <div class="form-group">
        <div class="label">
          <label>课时：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="class_hour" id="class_hour" data-validate="required:请输入课时" />
          <span style="margin-left: 10px; color: red;">*</span>
          <div class="tips"> </div>
        </div>
      </div>

	  
	  <div class="form-group">
	    <div class="label">
	      <label>学分：</label>
	    </div>
	    <div class="field">
	      <input type="text" class="input w50" value="" name="credit" id="credit" data-validate="required:请输入学分"/>
	      <div class="tips"> </div>
	    </div>
	  </div>


	  
	  <div class="form-group">
		<div class="label">
		  <label>课组名字：</label>
		</div>
		<div class="field">
		  <input type="text" class="input w50"  name="course_group_name" id="course_group_name" data-validate="required:请输入课组名字" />
		  <span style="margin-left: 10px; color: red;">*</span>
		  <div class="tips"> </div>
		</div>
	  </div>
      
        <div class="form-group">
		  <div class="label">
		    <label>简介：</label>
		  </div>
		  <div class="field">
		    <input type="text" class="input w50"  name="introduction" id="introduction" />
		    <div class="tips"> </div>
		  </div>
        </div>
     
	 <div class="form-group">
	   <div class="label">
	     <label>备注：</label>
	   </div>
	   <div class="field">
	     <input type="text" class="input w50" value="" name="remark" id="remark"  />
	     <div class="tips"> </div>
	   </div>
	 </div>
   
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="button" id="button bg-main icon-check-square-o" onclick="check1()"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>

<script src="js/jquery.min.js"></script>
<script type="text/javascript">
	$(function () {
        // $.ajax({
        //     type:"POST",
		// 	dataType:"json",
        //     url:"/workview/superviseadd1",
        //     processData : false,
        //     contentType : false,
        //     cache:false,
        //     async: false,
        //     data:({
        //         course_id: course_id,
        //         course_name: course_name,
        //         college_name: college_name,
        //         performance_rule_id: performance_rule_id,
        //         class_hour: class_hour,
        //         credit: credit,
        //         course_group_name: course_group_name,
        //         introduction: introduction,
        //         remark: remark
        //     }),
        //     success:function(data){
        //         console.log(data);
        //         if(data.status==401){
        //             alert("熔断开启，系统异常");
        //             window.location.href="login.html";
        //             return;
        //         }
        //         if(data.status==200) {
        //             localStorage.setItem("supervise",data.data);
        //             window.location.href="adminlist.html";
        //             return;
        //         }
        //         if(data.status==500) {
        //             alert("添加失败");
        //             window.location.href="adminlist.html";
        //             return;
        //         }
        //         if(data.status==null) {
        //             alert("添加异常");
        //             window.location.href="adminlist.html";
        //             return;
        //         }
        //     },
        //     error:function(XMLHttpRequest,textStatus) {
        //         if (textStatus === 'timeout') {
        //             alert('請求超時');
        //             setTimeout(function () {
        //                 alert('重新请求');
        //             }, 2000);
        //         }
        //         // window.location.href="login.html";
        //         alert("系统异常ajax失败");
        //     }
		//
        // });


    })
	    function check1(){
            var course_id = document.getElementById("course_id").value;
            var course_name = document.getElementById("course_name").value;
            var college_name = document.getElementById("college_name").value;
            var performance_rule_id = document.getElementById("performance_rule_id").value;
            var class_hour = document.getElementById("class_hour").value;
            var credit = document.getElementById("credit").value;
            var course_group_name = document.getElementById("course_group_name").value;
            var introduction = document.getElementById("introduction").value;
            var remark = document.getElementById("remark").value;

	    if(course_id == null || course_id == ""){
	        alert("工号不能为空");
	        return;
	    }

	    if(course_name == null || course_name == ""){
	        alert("课程名字不能为空");
	        return;
	    }
	    if(college_name == null || college_name == ""){
	        alert("学院名字不能为null");
	        return;
	    }
		if(performance_rule_id == null || performance_rule_id == ""){
		    alert("规则不能为null");
		    return;
		}
		if(class_hour != class_hour ){
		    alert("学时不能为null");
		    return;
		}
		if(credit == null || credit == ""){
		    alert("学分不能为null");
		    return;
		}
		if(course_group_name == null || course_group_name == ""){
		    alert("课程组名称不能为null ");
		    return;
		}

	    $.ajax({
            type:"POST",
            dataType:"json",
            url:"/workview/insertCourse_library",
	        data:({
				course_id: course_id,
                course_name: course_name,
                college_name: college_name,
                performance_rule_id: performance_rule_id,
                class_hour: class_hour,
                credit: credit,
                course_group_name: course_group_name,
                introduction: introduction,
                remark: remark
				}),
	        success:function(data){
	                console.log(data);
	                if(data.status==401){
	                    alert("熔断开启，系统异常");
	                    window.location.href="login.html";
	                    return;
	                }
	                if(data.status==200) {
	                    localStorage.setItem("supervise",data.data);
	                    window.location.href="course_librarylist.html";
	                    return;
	                }
	                if(data.status==500) {
	                    alert("添加失败");
	                    window.location.href="course_librarylist.html";
	                    return;
	                }
	                 if(data.status==null) {
	                    alert("添加异常");
	                    window.location.href="course_librarylist.html";
	                    return;
	                 }
	        },
	        error:function(XMLHttpRequest,textStatus) {
	            if (textStatus === 'timeout') {
	                alert('請求超時');
	                setTimeout(function () {
	                    alert('重新请求');
	                }, 2000);
	            }
	           // window.location.href="login.html";
                alert("系统异常ajax失败");
	        }
	
	    });
	
	}
	
	
</script>
</body>
</html>